import Vue from "vue";
import Router from "vue-router";
import routes from "./routes";
import NProgress from "nprogress";
NProgress.configure({
  showSpinner: false,
  easing: "ease",
  speed: 250
});

Vue.use(Router);

const router = new Router({
  mode: "hash",
  fallback: false,
  scrollBehavior() {
    return { x: 0, y: 0 };
  },
  routes
});

router.beforeEach(async (to, from, next) => {
  NProgress.start();
  next();
});

router.afterEach(() => {
  NProgress.done();
});

export default router;
